package com.winsdom.mapper;

import com.winsdom.entity.ReadingRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 抄表记录表 Mapper 接口
 * </p>
 *
 * @author 
 * @since 2025-05-12
 */
@Mapper
public interface ReadingRecordMapper extends BaseMapper<ReadingRecord> {
    @Select("SELECT *\n" +
            "FROM reading_record\n" +
            "WHERE \n" +
            "    table_id = #{id}\n" +
            "    AND read_time BETWEEN STR_TO_DATE(CONCAT(#{date}, '-01'), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(#{date} , '-31 23:59:59'), '%Y-%m-%d %H:%i:%s')")
    ReadingRecord getReadingRecordByIdAndLastTime(@Param("id") Integer id,@Param("date") String date);


}
